{extend name="main/index" /}
{block name="main"}
<!-- Start right content -->
<div class="content-page">
    <!-- ============================================================== -->
    <!-- Start Content here -->
    <!-- ============================================================== -->
    <div class="content">
        <!-- Page Heading Start -->
        <div class="page-heading">
            <h1><i class='fa fa-table'></i> 角色管理</h1>
            <h3>角色列表</h3></div>
        <!-- Page Heading End-->                <!-- Your awesome content goes here -->
        <div class="row">

            <div class="col-md-12">
                <div class="widget">
                    <div class="widget-header transparent">
                        <h2><strong>角色列表</strong> Table</h2>
                        <div class="additional-btn">
                            <a href="#" class="hidden reload"><i class="icon-ccw-1"></i></a>
                            <a href="#" class="widget-toggle"><i class="icon-down-open-2"></i></a>
                            <a href="#" class="widget-close"><i class="icon-cancel-3"></i></a>
                        </div>
                    </div>
                    <div class="widget-content">
                        <div class="table-responsive">
                            <table data-sortable class="table">
                                <thead>
                                <tr>
                                    <th>ID</th>
                                    <th style="width: 30px" data-sortable="false">
                                        <input type="checkbox" class="rows-check"></th>
                                    <th>角色名</th>
                                    <th>说明</th>
                                    <th>状态</th>
                                    <th>权限</th>
                                    <th data-sortable="false">操作</th>
                                </tr>
                                </thead>

                                <tbody>
                                {volist name="list" id="v"}
                                <tr >
                                    <td>{$v['id']}</td>
                                    <td><input type="checkbox" class="rows-check"></td>
                                    <td><strong>{$v['name']}</strong></td>
                                    <td>{$v['remark']}</td>
                                    <td>{$v['status'] == 1? '启用' : '禁用'}</td>

                                    <td>
                                        <a href="{:url('admin/Role/readch', ['id'=>$v['id']])}" data-toggle="tooltip" title="" class="btn btn-default">查看详情</a>
                                    </td>

                                    <td>
                                        <!-- <div class="btn-group btn-group-xs"> -->

                                        <button data-id="{$v['id']}" class="btn btn-default del-btn">删除</button>
                                        <a href="{:url('admin/Role/edit', ['id'=>$v['id']])}" data-toggle="tooltip" title="" class="btn btn-default">编辑</a>
                                        <a href="{:url('admin/Role/roleList', ['id'=>$v['id']])}" data-toggle="tooltip" title="" class="btn btn-default">权限分配</a>
                                        <!-- </div> -->
                                    </td>

                                </tr>
                                {/volist}
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Modal -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
            <div class="modal-dialog" role="document">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel"></h4>
                    </div>
                    <div class="modal-body myBody">

                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                        <button type="button" class="btn btn-primary">Save changes</button>
                    </div>
                </div>
            </div>
        </div>




    </div>
    <!-- ============================================================== -->
    <!-- End content here -->
    <!-- ============================================================== -->

</div>
<!-- End right content -->
{js href="/static/index/js/jquery.min.js"}


<script>

  $('.del-btn').click(function () {
      var ac_id=$(this).attr('data-id');
      if(confirm('你确定要删除吗')){
          var obj=$(this).parent('tr');
           console.log(obj);
          delAjax(ac_id,obj);
      }

  });
  function delAjax(id,obj) {
      $.ajax({
          type:'delete',
          url:'/roles/'+id,
          dataType:'json',
          success:function (data){
              if(data.status){
                  alert(data.info);
                  obj.remove();

              }else{
                  alert(data.info);
              }
          },
          error: function (err) {
              alert('删除失败');

          }


      });

  }



</script>


{/block}